import 'package:enterprise_v6_app/generated/json/base/json_convert_content.dart';
import 'package:enterprise_v6_app/app/data/common/role_menu_tree_entity.dart';

RoleMenuTreeEntity $RoleMenuTreeEntityFromJson(Map<String, dynamic> json) {
  final RoleMenuTreeEntity roleMenuTreeEntity = RoleMenuTreeEntity();
  final List<RoleMenuTreeEntity>? children = (json['children'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<RoleMenuTreeEntity>(e) as RoleMenuTreeEntity).toList();
  if (children != null) {
    roleMenuTreeEntity.children = children;
  }
  final String? component = jsonConvert.convert<String>(json['component']);
  if (component != null) {
    roleMenuTreeEntity.component = component;
  }
  final RoleMenuTreeMeta? meta = jsonConvert.convert<RoleMenuTreeMeta>(json['meta']);
  if (meta != null) {
    roleMenuTreeEntity.meta = meta;
  }
  final String? metaStr = jsonConvert.convert<String>(json['metaStr']);
  if (metaStr != null) {
    roleMenuTreeEntity.metaStr = metaStr;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    roleMenuTreeEntity.name = name;
  }
  final String? path = jsonConvert.convert<String>(json['path']);
  if (path != null) {
    roleMenuTreeEntity.path = path;
  }
  final String? redirect = jsonConvert.convert<String>(json['redirect']);
  if (redirect != null) {
    roleMenuTreeEntity.redirect = redirect;
  }
  return roleMenuTreeEntity;
}

Map<String, dynamic> $RoleMenuTreeEntityToJson(RoleMenuTreeEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['children'] = entity.children?.map((v) => v.toJson()).toList();
  data['component'] = entity.component;
  data['meta'] = entity.meta?.toJson();
  data['metaStr'] = entity.metaStr;
  data['name'] = entity.name;
  data['path'] = entity.path;
  data['redirect'] = entity.redirect;
  return data;
}

extension RoleMenuTreeEntityExtension on RoleMenuTreeEntity {
  RoleMenuTreeEntity copyWith({
    List<RoleMenuTreeEntity>? children,
    String? component,
    RoleMenuTreeMeta? meta,
    String? metaStr,
    String? name,
    String? path,
    String? redirect,
  }) {
    return RoleMenuTreeEntity()
      ..children = children ?? this.children
      ..component = component ?? this.component
      ..meta = meta ?? this.meta
      ..metaStr = metaStr ?? this.metaStr
      ..name = name ?? this.name
      ..path = path ?? this.path
      ..redirect = redirect ?? this.redirect;
  }
}

RoleMenuTreeMeta $RoleMenuTreeMetaFromJson(Map<String, dynamic> json) {
  final RoleMenuTreeMeta roleMenuTreeMeta = RoleMenuTreeMeta();
  final bool? hidden = jsonConvert.convert<bool>(json['hidden']);
  if (hidden != null) {
    roleMenuTreeMeta.hidden = hidden;
  }
  final String? icon = jsonConvert.convert<String>(json['icon']);
  if (icon != null) {
    roleMenuTreeMeta.icon = icon;
  }
  final bool? primary = jsonConvert.convert<bool>(json['primary']);
  if (primary != null) {
    roleMenuTreeMeta.primary = primary;
  }
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    roleMenuTreeMeta.title = title;
  }
  return roleMenuTreeMeta;
}

Map<String, dynamic> $RoleMenuTreeMetaToJson(RoleMenuTreeMeta entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['hidden'] = entity.hidden;
  data['icon'] = entity.icon;
  data['primary'] = entity.primary;
  data['title'] = entity.title;
  return data;
}

extension RoleMenuTreeMetaExtension on RoleMenuTreeMeta {
  RoleMenuTreeMeta copyWith({
    bool? hidden,
    String? icon,
    bool? primary,
    String? title,
  }) {
    return RoleMenuTreeMeta()
      ..hidden = hidden ?? this.hidden
      ..icon = icon ?? this.icon
      ..primary = primary ?? this.primary
      ..title = title ?? this.title;
  }
}
